Modeless Dialog Boxes

Description

A modeless Xdialog differs from a modal dialog box in that you can leave the dialog box open while continuing to work on other parts of Alpha Anywhere. Up till now, all of the examples in this book have been for modal dialog boxes. Throughout Alpha Anywhere itself, we use modeless Xdialog boxes extensively. For example, the Query Genie, the Find by Key dialog, and the Index Selector are all modeless dialog boxes. The syntax for modeless dialog boxes is virtually identical to the syntax for modal dialog boxes. The only difference is that the command to display a modeless dialog box is:

ui_modeless_dlg_box(title, dialog_body, dialogevent)

In addition, the title and dialog_event parameters are not optional, whereas in the case of a modal dialog, the title parameter can be blank and the dialog_event parameter can be omitted. Following is an example of a very simple modeless Xdialog box.

ui_modeless_dlg_box("Name",<<%dlg%
Name: [.20name];
{lf};
;
%dlg%,<<%code%
if a_dlg_button = "close" then
   ui_modeless_dlg_close("name")
   end
end if
%code%)
images/XD_Simple Modeless.gif

Notice that when you click the X on the title bar, the dialog box does not close. In fact, the only way to close this dialog is to click the "Close" button. When you click this button, the dialog box event handler executes this command:

ui_modeless_dlg_close("name")

which closes the modeless dialog box. It is required that you explicitly include code in all modeless Xdialog boxes to close the dialog box. In order to enable users to close an Xdialog box by clicking the "X" on the title bar, you can include the {Can_Exit=event_name} command in the dialog box. For example:

ui_modeless_dlg_box("Name",<<%dlg%
{can_exit=close}
Name: [.20name];
{lf};
;
%dlg%,<<%code%
if a_dlg_button = "close" then
   ui_modeless_dlg_close("name")
   end
end if
if a_dlg_button = "name" then
   if name <> "" then
       ui_msg_box("Hello","Hello " + name)
   else
       ui_msg_box("Hello","Please type in your name")
   end if
   end
end if
%code%)

This script will display the following dialog box:

images/XD_Enabling the X to close.gif

See Also